home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / c / tcclib.exe / GETSTRNM.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-01-31  |  908 b   |  33 lines

  1. #include "tcclib.h"
  2. #include <alloc.h>
  3. #include <conio.h>
  4.  
  5. int select ( char *menu[], int items, int x1, int y1, int x2 );
  6.  
  7. int getstringnum ( char *menu[], int items, int x1, int y1, int x2, int y2 )
  8. {
  9.     int x, y, selection;
  10.     int xborder = 2, yborder = 1;
  11.     char *buffer;
  12.  
  13.     /* 1. Display pop-up menu */
  14.     if ((buffer = calloc ((x2-x1+1)*(y2-y1+1)*2, sizeof (char))) == NULL )
  15.         return (-1);
  16.     gettext (x1, y1, x2, y2, buffer);
  17.     BlockErase (x1, y1, x2, y2);
  18.     DrawBox (x1, y1, x2, y2);
  19.     for ( y = y1 + yborder, x = 0; y < y2 && x < items; ++x, ++y ) {
  20.         AtSay (x1+xborder, y, menu[x]);
  21.     }
  22.  
  23.     /* 2. Obtain selection */
  24.     selection = select (menu, items, x1 + xborder - 1, y1 + yborder, x2 - xborder + 1);
  25.  
  26.     /* 3. Erase pop-up menu and restore screen */
  27.     puttext (x1, y1, x2, y2, buffer);
  28.     free (buffer);
  29.  
  30.     return (selection);
  31. }
  32.  
  33.